﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MedicWeb.MedicService;

namespace MedicWeb.forms.Reports {
    public partial class TemplateList : SessionPage {
        protected void Page_Load(object sender, EventArgs e) {
            MainService ms = new MainService();
            string type = Request.QueryString["type"];
            PrintTemplate[] templates = ms.GetPrintTemplateList(GetSession(), type, false);
            lnkAdd.NavigateUrl = ResolveUrl("~/forms/Print/Edit/TemplateEdit.aspx?type=" + type);
            foreach (var template in templates) {
                var row = new TableRow();
                TableCell cellEdit = new TableCell();
                TableCell cellId = new TableCell();
                TableCell cellTitle = new TableCell();

                cellEdit.Controls.Add(new HyperLink() { CssClass = "edit", NavigateUrl = ResolveUrl("~/forms/Print/Edit/TemplateEdit.aspx?type=" + type + "&id=" + template.Id) });
                cellEdit.Width = 24;
                cellId.Text = "" + template.Id;
                cellTitle.Text = (template.Active ? "Активный: " : "") + template.Title;

                row.Cells.Add(cellEdit);
                row.Cells.Add(createDeleteCell(template));
                row.Cells.Add(cellId);
                row.Cells.Add(cellTitle);

                tblTemlates.Rows.Add(row);
            }

        }
    }
}